﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;
using System.IO;
using CNotebook;

namespace NotebookS2
{
    public partial class GLDetermination : RibbonForm
    {
        public GLDetermination()
        {
            InitializeComponent();
        }

        public string ConnectionString { get; set; }
        public DataTable GLDeterminationTable { get; set; }

        void BindGLDetermination()
        {
            AcctDeterminationManager oManager = new AcctDeterminationManager();

            oManager.ConnectionString = this.ConnectionString;
            oManager.Open();

            DataTable dt = oManager.GetAccountDetermination();

            oManager.Close();
            this.GLDeterminationTable = dt;
            gridControl1.DataSource = this.GLDeterminationTable;
            gridControl1.Refresh();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            AcctDeterminationManager oManager = new AcctDeterminationManager();
            oManager.ConnectionString = this.ConnectionString;
            oManager.Open();
            oManager.UpdateDetermination(this.GLDeterminationTable);
            oManager.Close();

            MessageBox.Show("G/L Determination is already updated!!!","Account Determination", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        private void GLDetermination_Load(object sender, EventArgs e)
        {

        }

        private void txtAcctCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            FND_GLACCOUNT oForm = new FND_GLACCOUNT();

            oForm.ConnectionString = this.ConnectionString;

            oForm.ShowDialog();

            gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["AcctCode"], oForm.SelectedGLAcctCode);
            gridView1.SetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["AcctName"], oForm.SelectedGLAcctName);

        }

        private void GLDetermination_Shown(object sender, EventArgs e)
        {
            BindGLDetermination();
        }
    }
}
